package com.example.mobile2032021606170hsy0413;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
    @Override
    public boolean isInMultiWindowMode() {
        return super.isInMultiWindowMode();
    }

    private TextView tvMainTitle;
    private Button btnMainSupplier;
    private Button btnMainBuy;
    private TextView tvMainEsult;
    private Button btnMainClose;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog dialong;
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
                        .setTitle("普通对话框")
                        .setIcon(R.mipmap.ic_launcher)
                        .setMessage("是否确定退出应用：")
                        .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                                MainActivity.this.finish();
                            }
                        })
                        .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });

                dialong = builder.create();
                dialong.show();
            }
    });
}

            private void initView() {
                tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
                btnMainSupplier = (Button) findViewById(R.id.btn_main_supplier);
                btnMainBuy = (Button) findViewById(R.id.btn_main_buy);
                tvMainEsult = (TextView) findViewById(R.id.tv_main_esult);
                btnMainClose = (Button) findViewById(R.id.btn_main_close);
            }
        }


